<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>事件捕获</title>
  <style>
    .fa {
      width: 400px;
      height: 400px;
      background-color: pink;
    }

    .son {
      width: 200px;
      height: 200px;
      background-color: red;
    }
  </style>
</head>

<body>
  <div class="fa">
    <div class="son"></div>
  </div>
  <script>
    // 事件捕获
    // 开启,第三个参数是true
    const fa = document.querySelector('.fa')
    const son = document.querySelector('.son')
    document.addEventListener('click', function () {
      alert('爷爷')
    }, true)

    fa.addEventListener('click', function () {
      alert('把把')
    }, true)

    son.addEventListener('click', function () {
      alert('儿子')
    }, true)
  </script>
</body>

</html>